<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Phpwarn extends Model
{
   use \App\Models\Traits\ScopeCompanySite;
   use \App\Models\Traits\Site;
    
    protected $table = 't_phpwarn';
    
    protected $primaryKey = 'pdi_index';
    
    protected $guarded = [];
    
    public $timestamps = false;
    
    public function getCompanyField() {
        return 'Co_ID';
    }
    
    public function getSiteField() {
        return 'pdi_areaid';
    }
    
    public function scopeDevice($query, $pdiIndex) {
        if($pdiIndex){
            return $query->where('pdi_devid', $pdiIndex);
        }
       return $query;
    }
	
	public function warnlog() {
        return $this->hasOne('\App\Models\WarnOperator','warn_id','pdi_index');
    }

    public function area() {
        return $this->hasOne('\App\Models\Area', 'AreaId', 'pdi_areaid');
    }
    
}
